<template>
  <view
    class="row jc-around"
    :class="[customClass, light ? 'tabs-light' : 'tabs']"
  >
    <view
      v-for="item in tabs"
      :key="item.value"
      class="fz28"
      :class="[
        tab.value === item.value ? 'color-theme' : light ? 'color-1' : 'colorF',
      ]"
      @click="clickTab(item)"
    >
      {{ item.title }}
    </view>
  </view>
</template>

<script>
export default {
  props: {
    light: {
      default: false,
      type: Boolean,
    },
    tabs: Array,
    initial: {
      default: 0,
      type: Number,
    },
    customClass: {
      default: "",
      type: String,
    },
  },
  data() {
    return {
      tab: this.tabs[this.initial],
    };
  },
  methods: {
    clickTab(item) {
      this.tab = item;
      this.$emit("change", item);
    },
  },
};
</script>
<style lang="scss" scoped>
.tabs {
  height: 0.76rem;
  background: rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 0.05rem 0 rgba(167, 110, 244, 0.5);
  border-radius: 0.04rem;
  border: 0.01rem solid rgba(255, 255, 255, 0.2);
}
.tabs-light {
  height: 0.38rem;
  background: #ffffff;
  border-radius: 0.08rem;
}
.color-theme {
  color: #a76ef4;
}
.color-1 {
  color: #333333;
}
</style>